package com.vilen.learn.java7.V3_1;



import java.util.ArrayList;
import java.util.List;

/**
 * 这里的代码具体的实现是 SpreadsheetAgentFinder
 * 需要使用 AOP 以前是用的工厂模式和服务定位器模式的各种变体
 * 来解决这类问题
 * Created by vilen on 2017/9/22.
 */
public class HollywoodService {
    public static List<Agent> getFriendlyAgents(){
        AgentFinder finder = new SpreadsheetAgentFinder();
        List<Agent> agents = finder.findAllAgents();
        List<Agent> friendlyAgents = filterAgents(agents,"Java Developers");
        return friendlyAgents; // 返回友善的经纪人
    }

    private static List<Agent> filterAgents(List<Agent> agents, String agentType) {
        List<Agent> filteredAgents = new ArrayList<>();
        for (Agent agent : agents) {
            if(agent.getType().equals("Java Developers")){
                filteredAgents.add(agent);
            }
        }
        return filteredAgents;
    }

    public static void main(String[] args) {
        getFriendlyAgents();
    }
}
